package com.zw.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.zw.annotation.Excel;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank;
import lombok.*;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 模板信息
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Schema(name = "template", description = "模板信息")
@TableName("pt_template")
public class Template implements Serializable {

    public static final int visible = 1;

    @Schema(description = "模板ID")
    @Excel(name = "模板名称")
    private Long id;

    @Schema(description = "模板名称")
    @NotBlank(message = "模板名称不能为空")
    @Excel(name = "模板名称")
    private String name;

    @Schema(description = "模板描述")
    @Excel(name = "模板描述")
    private String description;

    @Schema(description = "启用/禁用")
    @Excel(name = "启用/禁用", readConverterExp = "0=禁用,1=启用")
    private Integer status;

    @Schema(description = "创建时间")
    @TableField(fill = FieldFill.INSERT, updateStrategy = FieldStrategy.NEVER)
    @Excel(name = "创建时间", dateFormat = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;

    @Schema(description = "更新时间")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    @Excel(name = "创建时间", dateFormat = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;

    @TableField(exist = false)
    @Valid
    private List<TemplateColumns> templateColumns;

    @TableField(exist = false)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime startTime;

    @TableField(exist = false)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime endTime;

    @Schema(description = "删除标志")
    @TableLogic(value = "0", delval = "1")
    private Integer delFlag;
}
